<template>
  <el-row class="seal-manage-module">
    <el-col class="title">需求跟进</el-col>
    <el-col class="main-content">
      <el-row>
        <el-col>
          <div class="clearfix" style="padding: 20px 0;">
            <div class="fl">
              <el-radio-group v-model="searchForm.state">
                <el-radio-button label="已发布"></el-radio-button>
                <el-radio-button label="已达成"></el-radio-button>
                <el-radio-button label="已关闭"></el-radio-button>
                <el-radio-button label="草稿"></el-radio-button>
              </el-radio-group>
            </div>
            <div class="fr">
              <el-row type="flex" :gutter="24">
                <el-col>
                  <el-row :gutter="24">
                    <el-col>
                      <el-row type="flex">
                        <el-col :span="6" class="label">需求类型</el-col>
                        <el-col :span="18">
                          <el-select v-model="searchForm.demandType">
                            <el-option
                              v-for="item in searchForm.demandTypeOption"
                              :key="item.optionCode"
                              :label="item.optionValue"
                              :value="item.optionCode"
                            ></el-option>
                          </el-select>
                        </el-col>
                      </el-row>
                    </el-col>
                  </el-row>
                </el-col>
                <el-col class="search-content">
                  <el-input
                    placeholder="请输入搜索关键字"
                    suffix-icon="el-icon-search"
                    v-model="searchForm.contractContent"
                  ></el-input>
                </el-col>
              </el-row>
            </div>
          </div>
        </el-col>
        <el-col>
          <div v-for="item in list" :key="item.id">
            <item-detail
              :options="{subTitle: true, priceRange: true, preDeliverTime: true, designType: true}"
              :detailInfo="item.detailInfo"
            >
              <div slot="button">
                <div v-if="item.state === 1">
                  <el-button
                    type="text"
                    @click="routerToAnswer(item.id,1)"
                  >查看工厂应答({{item.infoTotal}})</el-button>
                  <el-button type="text" @click="closeDemand(item.id)">关闭需求</el-button>
                </div>
                <div v-if="item.state === 2">
                  <el-button
                    type="text"
                    @click="routerToAnswer(item.id,2)"
                  >查看设计师应答({{item.infoTotal}})</el-button>
                  <el-button type="text" @click="routerToDemandOrder(item.id)">查看需求订单</el-button>
                </div>
                <div v-if="item.state === 3">
                  <el-button
                    type="text"
                    @click="routerToAnswer(item.id,3)"
                  >查看设计师应答({{item.infoTotal}})</el-button>
                  <el-button type="text" @click="recallDemand(item.id)">重新发起</el-button>
                </div>
                <div v-if="item.state === 4">
                  <el-button type="text"> 继续编辑</el-button>
                </div>
              </div>
            </item-detail>
          </div>
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page.sync="currentPage"
            :page-size="100"
            layout="total, prev, pager, next"
            :total="total"
          ></el-pagination>
        </el-col>
      </el-row>
    </el-col>
  </el-row>
</template>
<script>
import ItemDetail from "./ItemDetail";
import { getProductMaterial } from "@/api";
export default {
  name: "productManage",
  components: {
    ItemDetail
  },
  data() {
    return {
      searchForm: {
        state: "已发布",
        demandType: "全部",
        keyWord: ""
      },
      total: 50,
      currentPage: 1,
      list: [
        {
          id: 1,
          detailInfo: {
            companyTitle: "北欧实木床双人床主卧现代简约公主床有温馨感",
            subTitle: "实木沙发",
            range: [5000, 10000],
            preDeliverTime: "2020-06-08",
            designType: "3D渲染"
          },
          infoTotal: 3
        },
        {
          id: 2,
          detailInfo: {
            companyTitle: "北欧实木床双人床主卧现代简约公主床有温馨感",
            subTitle: "实木沙发",
            range: [5000, 10000],
            preDeliverTime: "2020-06-08",
            designType: "3D渲染"
          },
          infoTotal: 3
        }
      ],
      activeName: "1",
      userDialogShow: false,
      authDialogShow: false,
      authColumns: [
        {
          prop: "stationNo",
          label: "姓名"
        },
        {
          prop: "demandType",
          label: "手机号"
        },
        {
          prop: "company",
          label: "操作日期"
        },
        {
          prop: "state",
          label: "授权状态"
        },
        {
          prop: "sign",
          label: "操作人"
        }
      ],
      planNo: "",
      columns: [
        {
          prop: "stationNo",
          label: "印章持有人"
        },
        {
          prop: "demandType",
          label: "工号"
        },
        {
          prop: "company",
          label: "手机号"
        },
        {
          prop: "state",
          label: "部门"
        },
        {
          prop: "sign",
          label: "职位"
        }
      ],
      contractData: [
        {
          demandType: " 001",
          company: "13984223950",
          state: " 总裁部",
          sign: " CEO",
          time: "2020-10-10 12:32:43"
        },
        {
          demandType: "002",
          company: "13984223950",
          state: "总裁部",
          sign: "---",
          time: "2020-10-10 12:32:43"
        }
      ],
      pageNum: 1,
      pageSize: 20,
      total: 0
    };
  },
  computed: {
    dialogTitle() {
      let title = "";
      if (this.activeName === "1") {
        title = "设计作品版权出售合同章";
      } else if (this.activeName === "2") {
        title = "商品打样合同章";
      } else if (this.activeName === "3") {
        title = "代加工合同章";
      }
      return title + "授权历史";
    }
  },
  watch: {
    "searchForm.state": {
      handler() {
        this.getTableList();
      }
    }
  },
  methods: {
    routerToAnswer(id, type) {
      if (type === 1) {
        this.$router.push({ name: "", query: { id } });
      }
      if (type === 2 || type === 3) {
        this.$router.push({ name: "", query: { id } });
      }
    },
    closeDemand(id) {},
    recallDemand(id) {},
    routerToDemandOrder(id) {},
    del(row) {
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          // this.$message({
          //   type: 'success',
          //   message: '删除成功!'
          // });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    },
    addDialog(type) {},
    authDialog(type) {},
    cancelUser() {},
    submitUser() {},
    handleCurrentChange(value) {
      this.currentPage = value;
      this.selectCallback();
    },
    selectCallback() {
      this.getTableList();
    },
    getTableList() {
      const params = {
        planNo: this.planNo,
        pageSize: this.pageSize,
        pageNum: this.pageNum
      };
      getProductMaterial(params).then(res => {
        if (res.data.code === "0") {
          this.contractData = res.data.data.rows;
          this.total = res.data.data.total;
        }
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.clearfix {
  &:after {
    visibility: hidden;
    display: block;
    font-size: 0;
    content: " ";
    clear: both;
    height: 0;
  }
}
.fl {
  float: left;
}
.fr {
  float: right;
}
.seal-manage-module {
  .title {
    margin-bottom: 20px;
    padding: 0 10px;
    height: 60px;
    line-height: 60px;
    box-shadow: 0px 2px 4px 0px #d1d9e2;
  }
  .main-content {
    background-color: #fff;
    padding: 10px;

    .seal {
      text-align: center;
      font-size: 16px;
      .card-title {
        color: #4d4d4d;
        font-weight: 500;
        margin: 10px 0;
      }
      .card-content {
        color: #808080;
        font-weight: 400;
        margin-bottom: 20px;
      }
    }
    .table {
      margin: 10px 0;
      .delete-btn {
        color: red;
      }
    }
  }
}
</style>